$(function(){
    setHeight();
    parallax();
    contentWayPoint();
});

window.onresize = function() {
    setHeight();
}

var setHeight = function() {
	var w = document.body.clientWidth;
	$("header").css("height", (w/2.4)+"px");
	$(".images").css("height", (w/2.75)+"px");

	var brief_backw = $(".brief_back").width();
	$(".brief_back").css("height", (brief_backw/1.8)+"px");
	$(".brief_back_img").css("height", (brief_backw/1.8)+"px");
}

var parallax = function() {
	$(window).stellar();
};

var isMobile = {
	Android: function() {
		return navigator.userAgent.match(/Android/i);
	},
	BlackBerry: function() {
		return navigator.userAgent.match(/BlackBerry/i);
	},
	iOS: function() {
		return navigator.userAgent.match(/iPhone|iPad|iPod/i);
	},
	Opera: function() {
		return navigator.userAgent.match(/Opera Mini/i);
	},
	Windows: function() {
		return navigator.userAgent.match(/IEMobile/i);
	},
	any: function() {
		return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
	}
};

var contentWayPoint = function() {
	$('.animate-box').waypoint( function( direction ) {
		$(this.element).addClass('item-animate');
		setTimeout(function() {
			$('body .animate-box.item-animate').each(function(k) {
				var el = $(this);
				setTimeout( function () {
					var effect = el.data('animate-effect');
					if ( effect === 'bounceIn') {
						el.addClass('animated bounceIn');
					} else if ( effect === 'bounceInLeft') {
						el.addClass('animated bounceInLeft');
					} else if ( effect === 'bounceInRight') {
						el.addClass('animated bounceInRight');
					} else {
						el.addClass('animated bounceInUp');
					}
					el.removeClass('item-animate');
					el.removeClass('animate-box');
				},  k * 100, 'easeInOutExpo' ); 
			});
		}, 100);

	}, { offset: '85%' });
};